// In order to *not* need this ignore, consider extracting the "web" version
// of your plugin as a separate package, instead of inlining it in the same
// package as the core of your plugin.
// ignore: avoid_web_libraries_in_flutter
import 'dart:async';

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

import '../platform_service.dart';
import 'platform_service_platform_interface.dart';
import 'web_platform/base_web_platform.dart';

/// A web implementation of the PlatformServicePlatform of the PlatformService plugin.
class PlatformServiceWeb extends PlatformServicePlatform {
  /// Constructs a PlatformServiceWeb
  PlatformServiceWeb();

  static late BaseWebPlatform _webPlatform;

  static void registerWith(Registrar registrar) {
    PlatformServicePlatform.instance = PlatformServiceWeb();
    _webPlatform = BaseWebPlatform();
  }

  /// Returns a [String] containing the version of the platform.
  @override
  Future<String?> getPlatformVersion() => _webPlatform.getPlatformVersion();

  @override
  Future<NDFilePickerResult> pickFile() => _webPlatform.pickFile();

  @override
  Future<List<NDFileInfo>> pickImages(
          {int maxCount = 8,
          bool enableCamera = false,
          bool isWaterMark = false,
          bool isWaterMarkTiled = false,
          List<ImageWaterMarkSettingModel>? waterMarkSettings}) =>
      _webPlatform.pickImages(
        maxCount: maxCount,
        enableCamera: enableCamera,
        isWaterMark: isWaterMark,
        isWaterMarkTiled: isWaterMarkTiled,
      );

  @override
  Future<NDFileInfo?> takePicture(
          {bool isWaterMark = false,
          bool isWaterMarkTiled = false,
          List<ImageWaterMarkSettingModel>? waterMarkSettings}) =>
      _webPlatform.takePicture(
        isWaterMark: isWaterMark,
        isWaterMarkTiled: isWaterMarkTiled,
        waterMarkSettings: waterMarkSettings,
      );
}
